function createTable() {
  const textarea = document.getElementById("createTableSql");
  const sqlStatement = textarea.value.trim();
  const responseMessage = document.getElementById("responseMessage");

  if (!sqlStatement.toUpperCase().startsWith("CREATE TABLE")) {
    responseMessage.innerHTML = "<p style='color: red;'>请检查 SQL 语句是否以 'CREATE TABLE' 开始</p>";
    return;
  }

  fetch("/createtable", {
    method: "POST",
    headers: {
      "Content-Type": "application/json",
    },
    body: JSON.stringify({ sql: sqlStatement }),
  })
    .then((response) => response.json())
    .then((data) => {
      responseMessage.innerHTML = data.success
        ? "<p style='color: green;'>表创建成功</p>"
        : `<p style='color: red;'>表创建失败: ${data.message}</p>`;
    })
    .catch((error) => {
      console.error("Error:", error);
      responseMessage.innerHTML = "<p style='color: red;'>请求失败，请检查控制台</p>";
    });
}
